class Solution:
    def findMinArrowShots1(self, points: List[List[int]]) -> int:
        if len(points) <= 1:
            return len(points)

        # 按照区间的左边界升序排列
        points.sort(key=lambda x: x[0])

        res = 1
        # 将第一个区间设置为可射区间
        rangeStart, rangeEnd = points[0][0], points[0][1]

        for i in range(1, len(points)):
            curr = points[i]
            if curr[0] <= rangeEnd:
                rangeStart = max(rangeStart, curr[0])
                rangeEnd = min(rangeEnd, curr[1])
            else:
                res += 1
                rangeStart, rangeEnd = curr[0], curr[1]

        return res


    def findMinArrowShots(self, points: List[List[int]]) -> int:
        if len(points) <= 1:
            return len(points)

        # 按照区间的右边界升序排列
        points.sort(key=lambda x: x[1])

        res = 1
        pos = points[0][1]
        for i in range(1, len(points)):
            curr = points[i]
            if curr[0] > pos:
                res += 1
                pos = curr[1]

        return res